/*
 * LightChangeEvent.java
 *
 * Created on February 5, 2008, 12:06 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
package event;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import Segments.Segment;

public class LightChangeEvent extends Event {

    Event root;
    Segment segment;
    int VERDE = 1;
    int ROJO = 0;
    int AMBAR = 3;
    static String N = System.getProperty("line.separator");

    public LightChangeEvent() {
    }
    //debo recibir segment tambien

    public LightChangeEvent(Segment segment) {


        this.root = segment.getRoot();
        this.segment = segment;


    }

    @Override
    public void run() {



        myLogger.debug("Executing At: " + this.evTime() + " event type:  " + this.getEventType());

        try {
            FileOutputStream out = new FileOutputStream("c:/temp/log.txt", true);
            PrintWriter miArchivo = new PrintWriter(out);
            miArchivo.write(this.objectId() + ",");
            miArchivo.write(this.evTime() + ",");
            miArchivo.write(segment.getId() + ",");
            miArchivo.write(this.evPosition() + ",");
            miArchivo.write(this.getEventType() + ",");
            miArchivo.println();
            miArchivo.close();
        } catch (IOException ioe) {
            System.out.println("Error en la creaci�n del archivo log.txt");
        }

        /*	if(this.getDesiredStatus() == VERDE)
        this.segment.agregarEvento(this.evTime()+25,LCE,this.objectId(),this.segment.getSize(),AMBAR,this.lane); //Cambiar Luz
        else
        if(this.getDesiredStatus() == ROJO)
        this.segment.agregarEvento(this.evTime()+25,LCE,this.objectId(),this.segment.getSize(),VERDE,this.lane); //Cambiar Luz
        else
        if(this.getDesiredStatus() == AMBAR)
        this.segment.agregarEvento(this.evTime()+25,LCE,this.objectId(),this.segment.getSize(),ROJO,this.lane); //Cambia Luz
         */
        myLogger.debug("Finishing At: " + this.evTime() + " event type:  " + this.getEventType());
        myStreetControllerAgent.setReady();


    }

    @Override
    public String toString() {
        return "LightChangeEvent";

    }
}
